// 专门发跟用户有关的接口，例如用户登录、获取用户资料等
import request from '@/utils/request'

// 封装一个做登录的接口
export function loginAPI (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data
  })
}

// 封装一个获取用户资料的接口
export const userinfoAPI = () => {
  return request({
    url: '/v1_0/user/profile'
  })
}

// 封装一个修改头像的接口
export const avatarAPI = (data) => {
  return request({
    url: '/v1_0/user/photo',
    method: 'patch',
    data
  })
}

// 封装一个修改资料的接口
export const editUserInfoAPI = (data) => {
  return request({
    url: '/v1_0/user/profile',
    method: 'patch',
    data
  })
}

// 封装一个关注用户的接口
export const followAPI = (id) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'post',
    data: {
      target: id
    }
  })
}
export const cancelFollowAPI = (id) => {
  return request({
    url: `/v1_0/user/followings/${id}`,
    method: 'delete'
  })
}
